import React, { Component } from 'react'
import { Route, Switch } from 'react-router-dom'
// 路由组件放在pages文件夹
import Home from './pages/Home'
import About from './pages/About'
import Ceshi from './pages/Ceshi'
// 一般组件放在components文件夹
import Header from './components/Header'
import MyNavLink from './components/MyNavLink'

export default class App extends Component {
  render() {
    return (
      <div>
        <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <Header></Header>
          </div>
        </div>
        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">
              {/* 封装NavLink */}
              <MyNavLink to="/about">About</MyNavLink>
              {/* 模糊匹配 */}
              <MyNavLink to="/home/a/b">Home</MyNavLink>
              {/* 严格匹配 */}
              <MyNavLink to="/ceshi/a">严格匹配</MyNavLink>
            </div>
          </div>
          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                {/* 注册路由 */}
                <Switch>
                  <Route path="/about" component={About} />
                  <Route path="/home" component={Home} />
                  <Route exact={true} path="/ceshi" component={Ceshi} />
                </Switch>
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
}
